package subjectlist;

public class C如何对字符串进行反转 {

    public static void main(String[] args) {
        String a = "abcde";

        System.out.println(reverse_str(a));
    }

    public static String reverse_str(String str) {
        char[] ch = str.toCharArray();
        int len = ch.length;
        char tmp;
        for (int i = 0, j = len - 1; i < j; i++, j--) {
            tmp = ch[i];
            ch[i] = ch[j];
            ch[j] = tmp;
        }
        return new String(ch);
    }
}
